﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace LED_Tester
{
    public partial class frmConfirmTheta : Form
    {
        public frmConfirmTheta()
        {
            InitializeComponent();
        }

        private double thetaDegree;

        private ArrayList thetaList = new ArrayList();

        public double ThetaDegree
        {
            get { return thetaDegree; }
            set { thetaDegree = value; }
        }

        private void frmConfirmTheta_Load(object sender, EventArgs e)
        {
            int index = (int)thetaDegree / 15;

            if (index > 11)
            {
                index = 11;
            }

            comboBox1.SelectedIndex = index;

            listBox1.Items.Clear();

            for (int i = 0; i < thetaList.Count; i++)
            {
                listBox1.Items.Add("C" + thetaList[i].ToString() + "-" + ((int)thetaList[i] + 180).ToString());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int temp = int.Parse(comboBox1.SelectedItem.ToString());

            int count = 0;

            for (int i = 0; i < thetaList.Count; i++)
            {
                if (temp == (int)thetaList[i])
                {
                    count++;
                }
            }

            if (count == 0)
            {
                thetaList.Add(temp);
            }

            thetaList.Sort();

            thetaDegree = temp;

            DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            thetaDegree = double.Parse(comboBox1.SelectedItem.ToString());
        }
    }
}
